package com.skyable.account.controller;

import com.skyable.common.constants.param.CommonParams;
import com.skyable.account.entity.BaseEntity;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * @author GaoYuan
 * @title: BaseController
 * @projectName spring-cloud-oauth2-demo
 * @description: TODO
 * @date 2021/4/1720:20
 */
public class BaseController {

    void setInsertInfo(BaseEntity entity, HttpServletRequest request) {
        entity.setCreateUser(request.getHeader(CommonParams.HEADER_USER_NAME));
        entity.setUpdateUser(request.getHeader(CommonParams.HEADER_USER_NAME));
        entity.setCreateTime(new Date());
        entity.setUpdateTime(new Date());
    }

    void setUpdateInfo(BaseEntity entity, HttpServletRequest request) {
        entity.setUpdateUser(request.getHeader(CommonParams.HEADER_USER_NAME));
        entity.setUpdateTime(new Date());
    }
}
